package com.qd.common.panda.domain.entity.hk;

import cn.hutool.core.math.Money;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 临停订单
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class HkParkOrderDTO extends BaseQuery {
    @ExcelIgnore
    @JsonIgnore
    private static final String EXCEL_TITLE = "停车订单";

    /**
     * 主键
     */
    @ExcelProperty(value = {EXCEL_TITLE, "订单ID"})
    @NotBlank(message = "订单记录ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "订单记录ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String orderLogId;
    /**
     * 停车唯一标识
     */
    @ExcelIgnore
    @NotBlank(message = "停车唯一标识不能为空", groups = DefaultGroup.class)
    @Size(max = 32, message = "停车唯一标识长度不能超过{max}位", groups = DefaultGroup.class)
    @JsonProperty("inUnid")
    private String inUnid;
    /**
     * 账单编号
     */
    @ExcelProperty(value = {EXCEL_TITLE, "海康订单编号"})
    @Size(max = 64, message = "账单编号长度不能超过{max}位", groups = DefaultGroup.class)
    private String billCode;
    /**
     * 熊猫泊车车牌颜色
     */
    @ExcelIgnore
    private Integer vehicleColor;
    /**
     * 海康车牌颜色
     */
    @ExcelIgnore
    private Integer plateColor;
    /**
     * 车辆进场时间
     */
    @ExcelIgnore
    private Long enterTime;
    /**
     * 车辆进场时间显示
     */
    @ExcelIgnore
    private LocalDateTime enterTimeDisplay;
    /**
     * 结算时间
     */
    @ExcelIgnore
    private Long costTime;
    /**
     * 结算时间显示
     */
    @ExcelIgnore
    private LocalDateTime costTimeDisplay;
    /**
     * 停车时长
     */
    @ExcelIgnore
    private Integer parkPeriodTime;
    /**
     * 总收费金额/账单总额
     */
    @ExcelIgnore
    private Integer totalCost;
    /**
     * 总收费金额/账单总额显示，单位元
     */
    @ExcelProperty(value = {EXCEL_TITLE, "账单金额"})
    private String totalCostDisplay;
    /**
     * 优惠金额
     */
    @ExcelIgnore
    private Integer deductMoney;
    /**
     * 优惠金额显示，单位元
     */
    @ExcelProperty(value = {EXCEL_TITLE, "优惠金额"})
    private String deductMoneyDisplay;
    /**
     * 待支付金额/欠费金额
     */
    @ExcelIgnore
    private Integer payMoney;
    /**
     * 待支付金额/欠费金额显示，单位元
     */
    @ExcelProperty(value = {EXCEL_TITLE, "支付金额"})
    private String payMoneyDisplay;
    /**
     * 欠费时间
     */
    @ExcelIgnore
    private Long arrearsTime;
    /**
     * 欠费时间显示
     */
    @ExcelIgnore
    private LocalDateTime arrearsTimeDisplay;
    /**
     * 泊位编号
     */
    @ExcelIgnore
    @Size(max = 64, message = "泊位编号长度不能超过{max}位", groups = DefaultGroup.class)
    private String berthCode;
    /**
     * 添加时间
     */
    @ExcelIgnore
    private LocalDateTime addTime;
    /**
     * 支付状态:0未支付1支付成功2支付失败3已支付4取消支付
     */
    @ExcelIgnore
    private Integer payStatus;
    /**
     * 支付状态显示
     */
    @ExcelIgnore
    private String payStatusDisplay;
    /**
     * 支付时间
     */
    @ExcelProperty(value = {EXCEL_TITLE, "支付时间"})
    private LocalDateTime payTime;
    /**
     * 手机号
     */
    @ExcelProperty(value = {EXCEL_TITLE, "手机号"})
    @Size(max = 20, message = "手机号长度不能超过{max}位", groups = DefaultGroup.class)
    private String phone;
    /**
     * 车牌
     */
    @ExcelProperty(value = {EXCEL_TITLE, "车牌"})
    @Size(max = 20, message = "车牌长度不能超过{max}位", groups = DefaultGroup.class)
    private String plateNumber;
    /**
     * 业务ID
     */
    @ExcelIgnore
    @Size(max = 50, message = "业务ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String bid;
    /**
     * 订单类型:1:临停2欠费
     */
    @ExcelIgnore
    @NotNull(message = "订单类型:1:临停2欠费不能为空", groups = DefaultGroup.class)
    private Integer orderType;
    /**
     * 订单类型显示
     */
    @ExcelProperty(value = {EXCEL_TITLE, "订单类型"})
    private String orderTypeDisplay;
    /**
     * 停车场
     */
    @ExcelProperty(value = {EXCEL_TITLE, "停车场ID"})
    @Size(max = 50, message = "停车场长度不能超过{max}位", groups = DefaultGroup.class)
    private String parkId;
    /**
     * 停车场名称
     */
    @ExcelProperty(value = {EXCEL_TITLE, "停车场名称"})
    private String parkName;
    /**
     * 用户ID
     */
    @ExcelIgnore
    @Size(max = 50, message = "用户ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String userId;
    /**
     * 推送状态 -1未推送 0推送成功 1推送失败
     */
    @ExcelIgnore
    private Integer pushState;
    /**
     * 推送状态显示
     */
    @ExcelIgnore
    private String pushStateDisplay;
    /**
     * 支付方式:1:微信支付2钱包支付
     */
    @ExcelIgnore
    private Integer payMethod;
    /**
     * 支付方式显示
     */
    @ExcelProperty(value = {EXCEL_TITLE, "支付方式"})
    private String payMethodDisplay;
    /**
     * 钱包支付充值金额，单位元
     */
    @ExcelIgnore
    private BigDecimal walletAmount;
    /**
     * 钱包支付充值金额显示，单位元
     */
    @ExcelIgnore
    private BigDecimal walletGiveAmount;

    public String getTotalCostDisplay() {
        if (null == totalCost) {
            return "0.00";
        }
        return new Money(0, totalCost).getAmount().toString();
    }

    public String getDeductMoneyDisplay() {
        if (null == deductMoney) {
            return "0.00";
        }
        return new Money(0, deductMoney).getAmount().toString();
    }

    public String getPayMoneyDisplay() {
        if (null == payMoney) {
            return "0.00";
        }
        return new Money(0, payMoney).getAmount().toString();
    }

    @Override
    public void freeData() {
        this.orderLogId = null;
        this.inUnid = null;
        this.billCode = null;
        this.vehicleColor = null;
        this.plateColor = null;
        this.enterTime = null;
        this.enterTimeDisplay = null;
        this.costTime = null;
        this.costTimeDisplay = null;
        this.parkPeriodTime = null;
        this.totalCost = null;
        this.totalCostDisplay = null;
        this.deductMoney = null;
        this.deductMoneyDisplay = null;
        this.payMoney = null;
        this.payMoneyDisplay = null;
        this.arrearsTime = null;
        this.arrearsTimeDisplay = null;
        this.berthCode = null;
        this.addTime = null;
        this.payStatus = null;
        this.payStatusDisplay = null;
        this.payTime = null;
        this.phone = null;
        this.bid = null;
        this.orderType = null;
        this.orderTypeDisplay = null;
        this.parkId = null;
        this.plateNumber = null;
        this.userId = null;
        this.pushState = null;
        this.pushStateDisplay = null;
        this.payMethod = null;
        this.payMethodDisplay = null;
        this.walletAmount = null;
        this.walletGiveAmount = null;
        this.parkName = null;
        super.freeData();
    }
}